package com.his.check.controller;
import com.his.common.Result;
import com.his.check.pojo.Employee;
import com.his.check.pojo.MedicalTechnology;
import com.his.check.pojo.Register;
import com.his.check.service.CheckService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.ArrayList;


@RestController
@CrossOrigin("*")
@RequestMapping("check")
public class CheckController {
    @Resource
    private CheckService checkService;

    @GetMapping("query")
    public Result queryAllCheck(){
        ArrayList<Register> check=checkService.queryAllCheck();
        System.out.println(check);
        if(check!=null){
            return new Result(1,"查询检验申请信息列表成功！",check);
        }
        else{
            return new Result(0,"查询检验申请信息列表失败！",null);
        }
    }

    @PostMapping("select")
    public Result queryCheckByConditions(@RequestBody Register register){
        ArrayList<Register> list=checkService.queryCheckByConditions(register);
        System.out.println(list);
        if(list!=null){
            return new Result(1,"条件查询检验申请信息成功！",list);
        }
        else{
            return new Result(0,"条件查询检验申请信息失败！",null);
        }
    }
    //根据id拿到患者信息
    @PostMapping("lectById")
    public Result selectById(Integer id){
        Register register =checkService.selectById(id);
        System.out.println(register);
        return Result.success(register);
    }

    @PostMapping("select1")
    public Result queryEmployeeByConditions(@RequestBody Employee employee){
        ArrayList<Employee> list=checkService.queryEmployeeByConditions(employee);
        if(list!=null){
            return new Result(1,"条件查询检验申请信息成功！",list);
        }
        else{
            return new Result(0,"条件查询检验申请信息失败！",null);
        }
    }
    @PostMapping("select2")
    public Result queryMedicalTechnologyByConditions(Integer id) {
        ArrayList<MedicalTechnology> medicalTechnologyArrayList=checkService.queryMedicalTechnonlgyByConditions(id);
        if(medicalTechnologyArrayList!=null){
            return new Result(1,"条件查询检验申请信息成功！",medicalTechnologyArrayList);
        }
        else{
            return new Result(0,"条件查询检验申请信息失败！",null);
        }
    }
}
